package cn.kuick.deal.alert.resource;

import kafka.javaapi.producer.Producer;
import kafka.producer.KeyedMessage;
import kafka.producer.ProducerConfig;

import java.util.Properties;

/**
 * Created by Administrator on 2016/12/19.
 */
public class ProductTest {
    public static void main(String[] args) {
        String topicName = "behaviour-log";

        Properties properties = new Properties();
        properties.put("serializer.class", "kafka.serializer.StringEncoder");
        properties.put("metadata.broker.list", "10.22.10.139:9092");

        ProducerConfig producerConfig = new ProducerConfig(properties);
        Producer<Integer, String> producer = new Producer<Integer, String>(producerConfig);

        String message = "{'appId':'test', 'kuickUserId':'huang', 'userId':'user1', 'userName':'userNum1', 'content':'forTest', 'action':'create', 'createdTime':'2016-11-11 11:06:00', " +
                " 'userType':1, 'customerId':'1101', 'customerName':'testCustomer'}";

        producer.send(new KeyedMessage(topicName, message));
    }
}
